﻿
CREATE PROC usp_PerformanceHourly_Build
AS


--INSERT INTO [dbo].[PerformanceHourly] (RoleRowId, PerformanceCounterRowId, InstanceNumber, DateTimeUTC, MinValue, MaxValue, AverageValue, StdDev)
SELECT A.RoleRowId, A.PerformanceCounterRowId, A.InstanceNumber, A.DateTimeUTC, A.MinValue, A.MaxValue, A.AverageValue, IsNull(A.StdDev, 0) AS StdDev
FROM [dbo].[vw_PerformanceSample_Hourly] A
	RIGHT OUTER JOIN [dbo].[PerformanceHourly] B
		ON A.DateTimeUTC = B.DateTimeUTC
			And A.RoleRowId = B.RoleRowId
			And A.PerformanceCounterRowId = B.PerformanceCounterRowId
			And A.InstanceNumber = B.InstanceNumber